package org.urchr.beorganized.api.impl;

import org.urchr.beorganized.api.base.PrivateBaseAPIServlet;
import org.urchr.beorganized.dao.NotesDAO;
import org.urchr.beorganized.dao.XMLDocumentBuilder;
import org.urchr.beorganized.dao.errors.GeneralException;

public class RemoveNote extends PrivateBaseAPIServlet {

	public RemoveNote() {
		skipBody = true;
	}
	
	@Override
	protected void doProcessPrivate() throws GeneralException {
		int noteID = NotesDAO.safeInt(request.getParameter("noteid"), -1);
		int parentID = NotesDAO.archiveNote(userID, noteID);
		XMLDocumentBuilder doc = new XMLDocumentBuilder();
		doc.getRootElement("note").setAttribute("id", ""+noteID);
		doc.getRootElement("note").setAttribute("parentid", ""+parentID);
		sendNode(doc.getRootElement());
	}

}
